import { getWedaAPI, createComponent, concatClassList, px2rpx } from '@cloudbase/weda-client'
import lifeCycle from './lowcode/lifecycle'
import stateFn from './lowcode/state'
import computedFuncs from './lowcode/computed'

import _hanlderaddUnit from './lowcode/handler/addUnit' 
import _hanlderisInternalIcon from './lowcode/handler/isInternalIcon' 
import _hanldertap from './lowcode/handler/tap' 

const app = new Proxy({}, { get: function(obj, prop){ return getWedaAPI()?.app?.[prop] }});
const $app = new Proxy({}, { get: function(obj, prop){ return app[prop] }});

const handlers = {
  addUnit: _hanlderaddUnit, 
  isInternalIcon: _hanlderisInternalIcon, 
  tap: _hanldertap, 
}

const widgetProps = {
  "id1": {
    "style": {
      "display": "inline-block"
    },
    "classList": [],
    "_order": 0,
    "widgetType": "gsd-h5-react:Container"
  },
  "id2": {
    "style": {},
    "classList": [],
    "_parentId": "id1",
    "_order": 0,
    "widgetType": "gsd-h5-react:Container"
  },
  "id3": {
    "style": {
      "width": "100%",
      "height": "100%",
      "display": "block"
    },
    "classList": [],
    "alt": "[icon]",
    "fit": "cover",
    "mode": "scaleToFill",
    "lazyLoad": false,
    "imgPreview": false,
    "maskClosable": true,
    "showMenuByLongpress": "",
    "_parentId": "id2",
    "_order": 0,
    "widgetType": "gsd-h5-react:Image"
  }
}





const evtListeners = {"onid2$tap": [
      {
          key: 'wauobq09ub9g',
          sourceKey: '$comp:tap',
          handler: function({event, data = {}}){ return this.$WEAPPS_COMP.props.events.tap({...event.detail, ...data}) },
          args: {
  "params": [
    {
      "target": ""
    }
  ]
},
          argsBinds: {}
        }
    ],}

const behaviors = []

const properties = {
  "src": {
    type: String,
    value: ""
  },
  "name": {
    type: String,
    value: "success"
  },
  "size": {
    type: Number,
    value: 48
  },
  "type": {
    type: String,
    value: "inner"
  },
  "color": {
    type: String,
    value: ""
  },
}

const events = [
  {name: "tap", },
]



const dataBinds = {
  id2: { 'classList': ($comp, lists, forItems, event, $context, $w) => {const $for = forItems; const $index=lists?.[0]?.currentIndex; return(
      concatClassList(
$comp.handler.isInternalIcon() ? $comp.props.data.name.indexOf('td:') != -1 ? `t-icon-${$comp.props.data.name.replace("td:", "")} t-icon ` : `lcap-icon-${$comp.props.data.name} lcap-icon` : ''
, widgetProps.id2.classList)
    )},'style': ($comp, lists, forItems, event, $context, $w) => {const $for = forItems; const $index=lists?.[0]?.currentIndex; return(
      px2rpx({...widgetProps.id2.style, ...(
$comp.handler.isInternalIcon() ? {"font-size": `${$comp.props.data.size/2}PX`, color: $comp.props.data.color} : {width: `${$comp.props.data.size/2}PX`, height: `${$comp.props.data.size/2}PX`,  color: $comp.props.data.color}
)})
    )}
  },
  id3: { 'src': ($comp, lists, forItems, event, $context, $w) => {const $for = forItems; const $index=lists?.[0]?.currentIndex; return(
      $comp.props.data.src
    )},'_waIf': ($comp, lists, forItems, event, $context, $w) => {const $for = forItems; const $index=lists?.[0]?.currentIndex; return(
      !$comp.handler.isInternalIcon()
    )}
  },
}

const query = {
}

const eventFlows = [
]

const config = {}
const datasetProfile = {};

createComponent({
  key: 'CLOUDBASE_STANDARD:Icon',
  behaviors,
  properties,
  events,
  handler: handlers,
  dataBinds,
  evtListeners,
  widgetProps,
  lifeCycle,
  stateFn,
  computedFuncs,
  config,
  datasetProfile,
  query,
  eventFlows,
  nativeMode: !!0,
})
